package org.dev.vlp.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.dev.vlp.exception.ApiException;

/**
 * Description
 * Param
 * return
 * Author:86184
 * Date: 2023/1/15
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum LanguageEnum {
    //越南语的相关操作
    vietnamese(1) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.vietnameseWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.vietId;
        }

//        @Override
//        public TableEnum getBookTableEnum() {
//            return TableEnum.vietnameseBook;
//        }
//
//        @Override
//        public TableEnum getWordBookTableEnum() {
//            return TableEnum.vietnameseWordBook;
//        }

//        @Override
//        public TableEnum getCharacterEnum(){return TableEnum.vietnameseCharacter;}
    },
    // 葡萄牙语
    portuguese(2) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.portugueseWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.portId;
        }
    },

    // 西班牙语
    spanish(3) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.spanishWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.spanId;
        }
    },

    // 乌尔都语
    urdu(4) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.urduWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.urduId;
        }
    },
    // 泰语
    thai(5) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.thaiWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.thaiId;
        }
    },

    //老挝语
    lao(6) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.laoWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.laoId;
        }
    },
    //缅甸语
    bur(7) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.burWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.burId;
        }
    },
    //印尼语
    ind(8) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.indWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.indId;
        }
    },
    //印地语
    hindi(9) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.hindiWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.hindiId;
        }
    },
    //波斯语
    pers(10) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.persWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.persId;
        }
    },
    //日语
    jp(11) {
        @Override
        public TableEnum getWordTableEnum() {
            return TableEnum.jpWord;
        }

        @Override
        public BookIdEnum getBookIdEnum() {
            return BookIdEnum.jpId;
        }
    };


    public static LanguageEnum get(Integer lanId){
        LanguageEnum[] values = LanguageEnum.values();
        for (LanguageEnum value : values) {
            if (value.lanId.equals(lanId)) {
                return value;
            }
        }

        throw new ApiException("language not support ->" + lanId);
    }


    public abstract TableEnum getWordTableEnum();

    public abstract BookIdEnum getBookIdEnum();

//    public abstract TableEnum getBookTableEnum();
//
//    public abstract TableEnum getWordBookTableEnum();

//    public abstract TableEnum getCharacterEnum();

    private Integer lanId;


    public enum TableEnum {

        // 越南语表名
        vietnameseWord("vlp_vi_word"),
//        vietnameseBook("vlp_vi_book"),
//        vietnameseWordBook("vlp_vi_word_book"),
//        vietnameseCharacter("vlp_vi_character"),
        // 葡萄牙语表名
        portugueseWord("vlp_port_word"),
        // 西班牙語表名
        spanishWord("vlp_span_word"),

        //  乌尔都语表名
        urduWord("vlp_urdu_word"),
        //  泰语表名
        thaiWord("vlp_thai_word"),

        //  老挝语表名
        laoWord("vlp_lao_word"),

        //  缅甸语表名
        burWord("vlp_bur_word"),
        //  印尼语表名
        indWord("vlp_ind_word"),
        //  印地语表名
        hindiWord("vlp_hindi_word"),
        //  日语表名
        jpWord("vlp_jp_word"),

        //波斯语
        persWord("vlp_pers_word");

        private String tableName;

        TableEnum(String tableName) {
            this.tableName = tableName;
        }

        public String getTableName() {
            return tableName;
        }

        public void setTableName(String tableName) {
            this.tableName = tableName;
        }
    }

    public enum BookIdEnum{
        // 越南语词书开始编号
        vietId(7),

        // 葡萄牙语词书开始编号
        portId(1),

        // 西班牙語词书开始编号
        spanId(12),

        urduId(17),
        thaiId(22),
        laoId(33),
        burId(41),
        persId(46),
        indId(50),
        hindiId(48),
        jpId(53);

        private int bookId;

        BookIdEnum(int id) {
            this.bookId = id;
        }

        public int getBookId() {
            return bookId;
        }
    }
}
